package com.integralPerformance.controller;

import com.integralPerformance.common.Result;
import com.integralPerformance.pojo.entity.JobPosition;
import com.integralPerformance.pojo.form.add.AddJobPosition;
import com.integralPerformance.pojo.form.update.UpdateJobPosition;
import com.integralPerformance.pojo.query.JobPositionQuery;
import com.integralPerformance.pojo.query.PointsCriteriaQuery;
import com.integralPerformance.pojo.vo.BaseVo;
import com.integralPerformance.pojo.vo.JobPositionVo;
import com.integralPerformance.service.impl.JobPositionServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/s2/jobPosition")
@Tag(name = "！新：岗位类型管理表", description = "岗位类型管理表")
public class JobPositionController {

    @Autowired
    JobPositionServiceImpl jobPositionService;

    //    curd
    @Operation(summary = "查询获取", description = "查询获取")
    @PostMapping("/getList")
    public Result<BaseVo<JobPositionVo>> getList(@RequestBody JobPositionQuery jobPositionQuery) {
        return jobPositionService.getList(jobPositionQuery);
    }

    @Operation(summary = "①获取岗位类别", description = "获取岗位类别")
    @GetMapping("/getType")
    public Result<?> getType() {
        return jobPositionService.getType();
    }

    @Operation(summary = "②根据岗位类别获取岗位等级和岗位等级对应名称", description = "获取岗位对应名称")
    @GetMapping("/getDetails/{type}")
    public Result<?> getDetails(@PathVariable String type) {
        return jobPositionService.getDetails(type);
    }

    @Operation(summary = "根据id删除", description = "由于关联的特殊性，申请管理中存在关联信息，不允许删除")
    @DeleteMapping("/deleteById/{id}")
    public Result<?> deleteById(@PathVariable String id) {
        return jobPositionService.deleteById(id);
    }

    @Operation(summary = "添加一个", description = "添加一个")
    @PostMapping("/addOne")
    public Result<?> addOne(@RequestBody AddJobPosition addJobPosition) {
        return jobPositionService.addOne(addJobPosition);
    }

    @Operation(summary = "根据id获取", description = "根据id获取")
    @GetMapping("/getOneById/{id}")
    public Result<JobPosition> getOneById(@PathVariable String id) {
        JobPosition byId = jobPositionService.getById(id);
        return Result.success(byId);
    }

    @Operation(summary = "修改更新", description = "修改更新")
    @PostMapping("/update")
    public Result<?> update(@RequestBody UpdateJobPosition updateJobPosition) {
        jobPositionService.updateById(updateJobPosition);
        return Result.success("修改成功");
    }



}
